<template>
	<view>
		<view class="top">
			<view class="back">
				<image class="back-img" @click="back" src="../../../static/index/fanhui.png" mode=""></image>
				<text class="back-name">历年捐赠明细</text>
			</view>
			<view class="seleteYare">
				<picker mode="date" :value="date" fields="year" :start="startDate" :end="endDate" @change="dateChange">
					<view class="year">{{date}}年度 <image src="../../../static/mine/xiajiantou.png" mode=""></image>
					</view>
				</picker>
			</view>
		</view>
		<view class="integral">
			<view class="integral-title">
				<text>{{date}}年度积分捐赠</text>
				<view class="text">累计捐赠{{integralList.length>0?'3000':'0'}}积分  
				
				<image @click="open" style="width: 32rpx;height: 16rpx;margin-left: 15rpx;" src="../../../static/mine/bottomjiantou.png" mode="" v-if="!isOpen"></image>
				<image @click="open" style="width: 32rpx;height: 16rpx;margin-left: 15rpx;" src="../../../static/mine/topjiantou.png" mode="" v-else></image>
				<!-- <image src="../../../static/mine/bottomjiantou.png" style="width: 30rpx;height: 16rpx;margin-left: 15rpx;" mode=""></image>        <custom-tab-bar direction="" :show-icon="" :selected="" @onTabItemTap="" /> -->
				</view>
			</view>
			<view class="content" v-if="integralList.length>0" v-show="isOpen">
				<scroll-view scroll-y="true" class="scrollx" :height="Height+'rpx'" >
					<view class="content-box" v-for="(item,index) in integralList" :key="index" style="overflow-y: hidden;">
						<view class="left">
							<text>{{item.day}}</text>
							<text>{{item.month}}月</text>
						</view>
						<view class="middle">
							<image src="../../../static/mine/public/banner2.png" mode=""></image>
						</view>
						<view class="right">
							<text>捐赠积分{{item.num}}积分</text>
							<text>空巢老人救助行动</text>
						</view>
					</view>
				</scroll-view>
			</view>
			<view class="content2" v-else>
				<text>这里是空空的哦</text>
				<text>让我们进行爱心接力，传递真爱，让爱传遍人间大地，温暖所有人吧</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			// 设置日期
			const currentDate = this.getDate({
				format: 'yyyy'
			})
			return {
				isOpen:true,//商品信息折叠
				Height:'546',
				date: currentDate,
				integralList: [{
					month: '11',
					day: '19',
					num: "1000"
				}, {
					month: '11',
					day: '19',
					num: "1000"
				}, {
					month: '11',
					day: '19',
					num: "1000"
				}, {
					month: '11',
					day: '19',
					num: "1000"
				}],
			}
		},
		computed: {
			startDate() {
				return this.getDate('start');
			},
			endDate() {
				return this.getDate('end');
			}
		},
		methods: {
			open(){
				this.isOpen = !this.isOpen
			},
			back() {
				uni.navigateBack()
			},
			//选择年月日弹框
			seleteYare() {

			},
			// 选择日期
			dateChange(e) {
				this.date = e.target.value.slice(0, 7);
				console.log(this.date.slice(0, 7));
			},
			// 获取年月日信息
			getDate(type) {
				const date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				if (type === 'start') {
					year = year - 60;
				} else if (type === 'end') {
					year = year + 2;
				}
				month = month > 9 ? month : '0' + month;
				// day = day > 9 ? day : '0' + day;
				// return `${year}-${month}`;
				return `${year}`;
			}
		}
	}
</script>

<style scoped lang="less">
	.content2{
		margin-top: 50rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: column;
		padding: 98rpx;
		text:first-child{
			font-size: 32rpx;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #333333;
		}
		text:last-child{
			font-size: 28rpx;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #999999;
			margin-top: 28rpx;
		}
	}
	.content-box {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding-bottom: 24rpx;
		border-bottom: 1px solid #efefef;
		margin-bottom: 30rpx;
	
		.right {
			display: flex;
			flex-direction: column;
			padding-bottom: 24rpx;
			margin-right: 10rpx;
	
			text:first-child {
				font-size: 36rpx;
				font-family: Source Han Sans CN;
				font-weight: bold;
				color: #333333;
			}
	
			text:last-child {
				font-size: 28rpx;
				font-family: Source Han Sans CN;
				font-weight: 500;
				color: #999999;
			}
		}
	
		.middle {
			width: 236rpx;
			height: 112rpx;
			margin: 0 20rpx;
	
			image {
				width: 100%;
				height: 100%;
			}
		}
	
		.left {
			display: flex;
			flex-direction: column;
			padding-bottom: 24rpx;
			margin-left: 10rpx;
	
			text:first-child {
				font-size: 36rpx;
				font-family: Source Han Sans CN;
				font-weight: bold;
				color: #333333;
			}
	
			text:last-child {
				font-size: 28rpx;
				font-family: Source Han Sans CN;
				font-weight: 500;
				color: #999999;
			}
		}
	}
	.integral{
		width: 90%;
		margin: 0 5%;
		height: auto;
		background: #FFFFFF;
		opacity: 1;
		border-radius: 20rpx;
		.content {
			width: 100%;
			height: auto;
			overflow: hidden;
		}
		.integral-title {
			padding: 40rpx 32rpx 20rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			
			text:first-child {
				font-size: 32rpx;
				font-family: Source Han Sans CN;
				font-weight: bold;
				color: #333333;
			}
			
			.text {
				font-size: 24rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #999999;
			}
		}
	}
	.year {
		font-size: 40rpx;
		font-family: Source Han Sans CN;
		font-weight: bold;
		color: #FFFFFF;
		padding: 40rpx;

		image {
			width: 30rpx;
			height: 26rpx;
			margin-left: 20rpx;
		}
	}

	.top {
		width: 100%;
		height: 276rpx;
		background: linear-gradient(146deg, #FF7200 0%, #F5BD91 100%);
		opacity: 1;
		margin-bottom: 70rpx;
		// position: fixed;
		// top: 0;
		// left: 0;
	}

	.back {
		padding-top: 60rpx;
		padding-left: 30rpx;
		width: 100%;
		display: flex;
		align-self: center;

		.back-img {
			width: 40rpx;
			height: 40rpx;
			margin-top: 10rpx;
		}

		.back-name {
			font-size: 18px;
			line-height: 31px;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #ffffff;
			margin-right: 28rpx;
		}
	}
</style>
